#include"../include/pwm.h"
//初始化PWM
void speed_init(const Speed_Handle&speedhandle)
{
    //建立LEDC通道
    ledcSetup(speedhandle.CHANNEL,speedhandle.FREQ,speedhandle.RESOLUTION);
    //关联GPIO口与LEDC通道
    ledcAttachPin(speedhandle.pin_speed,speedhandle.CHANNEL);
}
void servo_init(const Servo_Handle&servohandle){
    //建立LEDC通道
    ledcSetup(servohandle.CHANNEL,servohandle.FREQ,servohandle.RESOLUTION);
    //关联GPIO口与LEDC通道
    ledcAttachPin(servohandle.pin_servo,servohandle.CHANNEL);
}
//输入角度转换
int calculateServo(int degree)
{
 int min_width=0.5/20*pow(2,SERVOHANDLE.RESOLUTION);
 int max_width=2.5/20*pow(2,SERVOHANDLE.RESOLUTION);
return (max_width-min_width)/180*degree+min_width;
}